﻿using Autofac;
using CommunityToolkit.Mvvm.ComponentModel;
using DBContext;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoneLine.Models;

namespace ZoneLine.ViewModels
{
    public class StationResultInfoViewModel : ObservableObject
    {
        private IModelDAL _dal;
        public StationResultInfoViewModel(string code, bool isAbsCode = false)
        {
            _dal = ContainerServer.Container.Resolve<IModelDAL>();
            if (isAbsCode)
            {
                Op006StationInfo = _dal.GetModel<QOP006StationResult>(p => p.AbsScanCode == code);
                Op010StationInfo = _dal.GetModel<QOP010StationResult>(p => p.AbsScanCode == code);
                Op020StationInfo = _dal.GetModel<QOP020StationResult>(p => p.AbsScanCode == code);
                Op050LStationInfo = _dal.GetModel<QOP050LStationResult>(p => p.AbsScanCode == code);
                Op050RStationInfo = _dal.GetModel<QOP050RStationResult>(p => p.AbsScanCode == code);
            }
            else
            {
                Op006StationInfo = _dal.GetModel<QOP006StationResult>(p => p.Code == code);
                Op010StationInfo = _dal.GetModel<QOP010StationResult>(p => p.Code == code);
                Op020StationInfo = _dal.GetModel<QOP020StationResult>(p => p.Code == code);
                Op050LStationInfo = _dal.GetModel<QOP050LStationResult>(p => p.Code == code);
                Op050RStationInfo = _dal.GetModel<QOP050RStationResult>(p => p.Code == code);
            }

        }

        private QOP006StationResult _op006StationInfo;

        public QOP006StationResult Op006StationInfo
        {
            get { return _op006StationInfo; }
            set => SetProperty(ref _op006StationInfo, value);
        }

        private QOP010StationResult _op010StationInfo;

        public QOP010StationResult Op010StationInfo
        {
            get { return _op010StationInfo; }
            set => SetProperty(ref _op010StationInfo, value);
        }

        private QOP020StationResult _op020StationInfo;

        public QOP020StationResult Op020StationInfo
        {
            get { return _op020StationInfo; }
            set => SetProperty(ref _op020StationInfo, value);
        }

        private QOP050LStationResult _op050LStationInfo;

        public QOP050LStationResult Op050LStationInfo
        {
            get { return _op050LStationInfo; }
            set => SetProperty(ref _op050LStationInfo, value);
        }

        private QOP050RStationResult _op050RStationInfo;

        public QOP050RStationResult Op050RStationInfo
        {
            get { return _op050RStationInfo; }
            set => SetProperty(ref _op050RStationInfo, value);
        }
    }
}
